package com.jming.jike.common;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * @author jming
 * @date 2022/4/16
 */
@Data
public class PageResult<T> {

    @ApiModelProperty("第几页，从1开始")
    private int pageIndex = 1;

    @ApiModelProperty("每页大小")
    private int pageSize = 10;

    @ApiModelProperty("总行数")
    private int rowTotal;

    @ApiModelProperty("总共多少页")
    private int pageTotal;

    @ApiModelProperty("分页对象数据")
    private List<T> data;

    public PageResult(int pageIndex, int pageSize, int rowTotal, List<T> data) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.rowTotal = rowTotal;
        this.pageTotal = (this.rowTotal - 1 + this.pageSize) / this.pageSize;
        this.data = data;
    }

}

